home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MouseModuleHeader.c
-
- Contains: Mouse Module Header file
-
- Version: xxx put version here xxx
-
- Copyright: © 1997-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
-
- #include "MouseModule.h"
- #include "MouseModuleVersion.h"
-
- static OSStatus MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus MouseModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
- static OSStatus MouseNotifyProc(UInt32 notification, void *pointer, UInt32 refcon);
-
- extern usbMousePBStruct myMousePB;
- extern usbMousePBStruct watchDogPB;
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- 0, // vendor = not device specific
- 0, // product = not device specific
- 0, // version of product = not device specific
- kUSBMouseInterfaceProtocol, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- kUSBHIDInterfaceClass, // Interface Class
- kUSBBootInterfaceSubClass, // Interface SubClass
- kUSBMouseInterfaceProtocol, // Interface Protocol
-
-
- // Driver Info
- kMouseModuleName kMouseStringVersShort, // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kMouseHexMajorVers,
- kMouseHexMinorVers,
- kMouseCurrentRelease,
- kMouseReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch // Flags (currently undefined)
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- 0, // Hardware Validation Procedure
- MouseDeviceInitialize, // Initialization Procedure
- MouseInterfaceInitialize, // Interface Initialization Procedure
- MouseModuleFinalize, // Finalization Procedure
- MouseNotifyProc, // Driver Notification Procedure
- };
-
-
- // Initialization function
- // Called upon load by Expert
- static OSStatus MouseDeviceInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
- #pragma unused (pDesc)
- USBExpertStatus(device, kMouseModuleName": Entered via MouseDeviceInitialize! (ignored)", device);
- return (OSStatus)noErr;
- }
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
- {
- InterfaceEntry(interfacenum, pInterface, pDesc, device);
- ChainJADBProc();
- return (OSStatus)noErr;
- }
-
- static OSStatus MouseNotifyProc(UInt32 notification, void *pointer, UInt32 refcon)
- {
- #pragma unused (pointer)
- #pragma unused (refcon)
-
- OSStatus status = noErr;
-
- switch (notification)
- {
- case kNotifyExpertTerminating: // TCC <USB22>
- return(noErr);
- break;
- case kNotifyDriverBeingRemoved:
- myMousePB.driverRemovalPending = true;
- watchDogPB.driverRemovalPending = true;
-
- USBExpertStatus(myMousePB.interfaceRef, kMouseModuleName": Notification that driver removal is pending...", notification);
- if (myMousePB.pb.usbRefcon & kCompletionPending)
- {
- USBExpertStatus(myMousePB.interfaceRef, kMouseModuleName": Waiting for transaction to complete", myMousePB.pb.usbRefcon);
- if (myMousePB.pipeRef)
- {
- USBExpertStatus(myMousePB.interfaceRef, kMouseModuleName": Aborting interrupt pipe", myMousePB.pipeRef);
- if (USBAbortPipeByReference(myMousePB.pipeRef) != noErr){
- myMousePB.pb.usbRefcon &= ~kCompletionPending; // don't expect the completion to be called either
- }
- myMousePB.intPipeAborted = true;
- myMousePB.pipeRef = nil;
- }
- status = kUSBDeviceBusy;
- }
- break;
-
- default:
- break;
- } // switch
-
- return(status);
- }
-
-
- // Termination function
- // Called by Expert when driver is being shut down
- static OSStatus MouseModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
- //USBHIDData theMouseData;
-
- USBExpertStatus(theDeviceRef, kMouseModuleName": Finalize", 0);
-
- if (myMousePB.pCursorDeviceInfo != 0)
- {
- USBExpertStatus(theDeviceRef, kMouseModuleName": Removing CDM device", 0);
- CursorDeviceDisposeDevice(myMousePB.pCursorDeviceInfo);
- myMousePB.pCursorDeviceInfo = 0;
- }
- UnchainJADBProc();
-
- return (OSStatus)noErr;
- }
-
-